package org.kevin.service.impl;

import com.github.pagehelper.util.StringUtil;
import org.kevin.domain.Role;
import org.kevin.mapper.RoleMapper;
import org.kevin.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @ClassName: RoleServiceImpl
 * @Description: TODO
 * @Author: kevin
 * @Date: 2019/8/26 6:59 下午
 * @Version: 1.0
 */
@Service("roleService")
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> getRoles(Role role) {
        Example example = new Example(Role.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtil.isNotEmpty(role.getRoleName())) {
            criteria.andCondition("role_name=", role.getRoleName());
        }
        example.setOrderByClause("create_time");
        return this.roleMapper.selectByExample(example);
    }
}
